<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        .container {
            width: 400px;
            margin: 0 auto;
            text-align: center;
        }
        .square {
            width: 200px;
            height: 200px;
            background-color: red;
            margin: 0 auto;
        }
        </style>
        <div id="app" class="container">
        <div class="square" v-show="show"></div>
            <br />
            <button @click="toggle()">点击切换</button>
        </div>
        <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
        <script>
            const app = new Vue({
                el: "#app",
                data: {
                    show: true
                },
                methods: {
                    toggle () {
                        this.show =!this.show;
                    }
                }
            });
    </script> 
</body>
</html>
